home *** CD-ROM | disk | FTP | other *** search
/ Aminet 45 / Aminet 45 (2001)(GTI - Schatztruhe)[!][Oct 2001].iso / Aminet / game / role / ldmud-3.2-bin.lha / mud / doc / efun / first_inventory < prev    next >
Text File  |  2001-04-06  |  1KB  |  45 lines

  1. SYNOPSIS
  2.         object first_inventory()
  3.         object first_inventory(string ob)
  4.         object first_inventory(object ob)
  5.  
  6. DESCRIPTION
  7.         Get the first object in the inventory of ob, where ob is
  8.         either an object or the file name of an object. If ob is not
  9.         given, the current object is assumed.
  10.  
  11. EXAMPLES
  12.         This efun is mostly used in the following context:
  13.         
  14.         for(ob=first_inventory(container);ob;ob=next_inventory(ob)) {
  15.            <some actions>
  16.         }
  17.         
  18.         If you use such calls frequently then it would be very useful
  19.         to use a preprocessor macro:
  20.         
  21.         #define FORALL(x, y) for(x=first_inventory(y);x;x=next_inventory(x))
  22.         
  23.         So the above example could be written like this:
  24.         
  25.         FORALL(ob, container) {
  26.            <some actions>
  27.         }
  28.         
  29.         Warning: If the object ob is moved inside <some actions>, then
  30.         next_inventory() will return an object from the new inventory
  31.         of ob. You also shouldn't call next_inventory() on destructed
  32.         objects. So in case of move and/or destruction the following
  33.         is a better solution:
  34.         
  35.         for(ob=first_inventory(container);ob;) {
  36.            next=next_inventory(ob);
  37.            <some actions and moves and/or removes>
  38.            ob=next;
  39.         }
  40.         
  41.  
  42. SEE ALSO
  43.         next_inventory(E), all_inventory(E), environment(E),
  44.         deep_inventory(E)
  45.